home *** CD-ROM | disk | FTP | other *** search
- class classes.enemy.DroidD
- {
- var x;
- var y;
- var moveScript;
- var id;
- var clip;
- var f2;
- var dir;
- var axis;
- var xDest;
- var yDest;
- var oldDir;
- var xMov = 0;
- var yMov = 0;
- var xMovT = 0;
- var yMovT = 0;
- var speedOrig = 8;
- var speed = 8;
- var xDestMet = false;
- var yDestMet = false;
- var c = 0;
- var feelerInfo = [[-400,0,400,40],[0,0,400,40],[0,-400,40,400],[0,0,40,400]];
- var dirArray = ["L","R","U","D"];
- var power = 20;
- var Name = "droidD";
- function DroidD(px, py, pmoveScript, pid)
- {
- this.x = px;
- this.y = py;
- this.moveScript = pmoveScript.slice();
- this.id = pid;
- _root.d = _root.d + 1;
- this.clip = _root.attachMovie("droidA","droidD" + this.id + "Clip",_root.d + 50000);
- this.clip._x = this.x;
- this.clip._y = this.y;
- this.speed *= _root.dif.speed;
- this.speedOrig = this.speed;
- this.speedVar();
- var _loc3_ = new flash.geom.Transform(this.clip);
- var _loc4_ = new flash.geom.ColorTransform(0,0,0,1,-255,-255,-255,0);
- _loc3_.colorTransform = _loc4_;
- this.parseMoveScript();
- _root.stats.created = _root.stats.created + 1;
- }
- function speedVar()
- {
- if(random(3) == 1)
- {
- this.speed *= _root.randRange2(0.9999,1.0001);
- }
- }
- function bombed(num)
- {
- this.f2 = "death";
- }
- function parseMoveScript()
- {
- this.dir = this.moveScript[0];
- if(this.dir == "break")
- {
- delete this.moveScript;
- this[this.axis + "MovT"] = 0;
- this.f2 = "wander";
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.speedVar();
- this.getDirString();
- }
- else
- {
- this[this.axis + "MovT"] = 0;
- this.f2 = "gotoXYDest";
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.speedVar();
- if(this.dir == "L" || this.dir == "U")
- {
- this[this.axis + "Dest"] = this[this.axis] - this.moveScript[1];
- }
- else
- {
- this[this.axis + "Dest"] = this[this.axis] + this.moveScript[1];
- }
- this.moveScript.splice(0,2);
- }
- }
- function gotoXYDest()
- {
- if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
- {
- if(this.axis == "x")
- {
- this.x = this.xDest;
- }
- else
- {
- this.y = this.yDest;
- }
- this.parseMoveScript();
- }
- }
- function getDirString()
- {
- if(this.xMovT < -1)
- {
- this.dir = "L";
- }
- else if(this.xMovT > 1)
- {
- this.dir = "R";
- }
- else if(this.yMovT > 1)
- {
- this.dir = "D";
- }
- else if(this.yMovT < -1)
- {
- this.dir = "U";
- }
- }
- function attacking()
- {
- }
- function death()
- {
- _root.stats.destroyed = _root.stats.destroyed + 1;
- _root.stats.score += 100;
- _root.powerUpB(this.x,this.y,80,"doubleLaserA",2);
- _root.createExploD([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(80,130),_root.randRange(75,100)]);
- var _loc3_ = 0;
- var _loc4_ = random(3);
- while(_loc3_ < _loc4_)
- {
- _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"droidA","",false,true]);
- _loc3_ = _loc3_ + 1;
- }
- _root.audio.playLevel4("droidX" + (random(3) + 1),_root.randRange(16,35));
- _root.removeChar("droidD" + this.id);
- this.f2 = "";
- }
- function wander()
- {
- if(random(100) > 96 + _root.dif.wander)
- {
- this[this.axis + "MovT"] = 0;
- this.axis = this.axis != "x" ? "x" : "y";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- }
- function death2()
- {
- _root.removeChar("droidD" + this.id);
- this.f2 = "";
- }
- function main()
- {
- this[this.f2]();
- if(this.oldDir != this.dir)
- {
- this.clip.gotoAndStop("fly" + this.dir);
- }
- this.oldDir = this.dir;
- var _loc4_ = 0;
- var _loc6_ = _root.broShots.length;
- while(_loc4_ < _loc6_)
- {
- var _loc5_ = _root.broShots[_loc4_] + "Clip";
- if(this.clip.hitTest(_root[_loc5_]))
- {
- this.f2 = "death";
- _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
- var _loc3_ = _root.broShots[_loc4_];
- _root[_loc3_].exploX = this.x + this.clip._width / 2;
- _root[_loc3_].exploY = this.y + this.clip._height / 2;
- _root[_loc3_].hit(1);
- break;
- }
- _loc4_ = _loc4_ + 1;
- }
- if(this.clip.hitTest(_root[_root.char + "Clip"]))
- {
- _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
- this.f2 = "death";
- }
- if(this.x > 1050 || this.x < -50 || this.y < -50 || this.y > 650)
- {
- this.f2 = "death2";
- }
- if(this.xMovT < this.xMov)
- {
- this.xMov -= 1;
- }
- else if(this.xMovT > this.xMov)
- {
- this.xMov += 1;
- }
- else
- {
- this.xMov = this.xMovT;
- }
- if(this.yMovT < this.yMov)
- {
- this.yMov -= 1;
- }
- else if(this.yMovT > this.yMov)
- {
- this.yMov += 1;
- }
- else
- {
- this.yMov = this.yMovT;
- }
- this.x += this.xMov;
- this.y += this.yMov;
- this.clip._x = this.x;
- this.clip._y = this.y;
- }
- }
-